package com.zygh.policeasset.service;

import com.zygh.policeasset.mapper.AssetsClassificationMapper;
import com.zygh.policeasset.pojo.AssetsClassification;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/service/AssetsClassificationService.class */
public class AssetsClassificationService {
    @Autowired
    AssetsClassificationMapper assetsClassificationMapper;

    public List<AssetsClassification> findAll() {
        List<AssetsClassification> list = this.assetsClassificationMapper.findAll();
        List<AssetsClassification> root = new ArrayList<>();
        for (AssetsClassification item : list) {
            if (item.getPid().intValue() == 0) {
                root.add(item);
            }
        }
        for (AssetsClassification item2 : root) {
            item2.setChild(getChild(item2.getId().intValue(), list));
        }
        return root;
    }

    public List<AssetsClassification> getChild(int id, List<AssetsClassification> all) {
        List<AssetsClassification> childList = new ArrayList<>();
        for (AssetsClassification item : all) {
            if (item.getPid().intValue() == id) {
                childList.add(item);
            }
        }
        for (AssetsClassification item2 : childList) {
            item2.setChild(getChild(item2.getId().intValue(), all));
        }
        if (childList.size() == 0) {
            return new ArrayList();
        }
        return childList;
    }
}